package com.jlpay.openapi.demo.clearing.upload;


import com.jlpay.open.jlpay.sdk.java.enums.DigestAlgorithmType;
import com.jlpay.open.jlpay.sdk.java.model.upload.request.VideoUploadReq;
import com.jlpay.open.jlpay.sdk.java.model.upload.response.FileUploadResponse;
import com.jlpay.openapi.demo.JlpayOpenApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

/**
 * @author xuexiaoya
 * @version 2024/03/07
 **/
public class FileUploadService {

    private static final Logger LOGGER = LoggerFactory.getLogger(FileUploadService.class);

    public static void main(String[] args) throws IOException {
        VideoUploadReq req = new VideoUploadReq();
        req.setFileName("AAA.mp4");
        //支持 SM3和sha256
        req.setAlg(DigestAlgorithmType.SM3);
        String filePath = "C:\\AAA.mp4";
        byte[] fileBytes = Files.readAllBytes(Paths.get(filePath));
        req.setFile(fileBytes);
        FileUploadResponse response = JlpayOpenApiService.uploadFileService().post(req, FileUploadResponse.class);
        LOGGER.info("视频上传结果查询响应:{}", response);
    }

}
